import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    //重定向
    // redirect:'/about',
    alias:'/c',  //别名
  },
  {
    path: '/about',
    name: 'About',
    // component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    components:{
      default:()=>import('../views/About.vue'),
      // a:comA,
      // b:comB,
      a:()=>import('../views/comA.vue'),
      b:()=>import('../views/comB.vue'),
    }
  },
  {
    path: '/news',
    name: 'News',
    component: () => import('../views/News.vue'),
    children:[
      {
        path:'newsDetail/:id/:i',
        component:()=>import('@/views/NewsDetail.vue'),
        props:true,
      }
    ]
  },
  {
    path:'/product',
    name:'Product',
    component:()=>import('../views/Product.vue')
  },
  {
    path:'*',
    component:()=>import('@/views/NotFound.vue'),
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
